/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'central';
  
@endpointMap = {
    cn-hangzhou = 'quickbi-public-share.aliyuncs.com',
    cn-hongkong = 'quickbi-public-share.aliyuncs.com',
    ap-southeast-1 = 'quickbi-public-share.aliyuncs.com',
    ap-southeast-3 = 'quickbi-public-share.aliyuncs.com',
    eu-central-1 = 'quickbi-public-share.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('quickbi-public', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model QueryDatasetDetailInfoRequest {
  datasetId?: string(name='DatasetId'),
}

model QueryDatasetDetailInfoResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  result?: string(name='Result'),
}

model QueryDatasetDetailInfoResponse = {
  headers: map[string]string(name='headers'),
  body: QueryDatasetDetailInfoResponseBody(name='body'),
}

async function queryDatasetDetailInfoWithOptions(request: QueryDatasetDetailInfoRequest, runtime: Util.RuntimeOptions): QueryDatasetDetailInfoResponse {
  Util.validateModel(request);
  var query = {};
  query["DatasetId"] = request.datasetId;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'QueryDatasetDetailInfo',
    version = '2020-08-06',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryDatasetDetailInfo(request: QueryDatasetDetailInfoRequest): QueryDatasetDetailInfoResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryDatasetDetailInfoWithOptions(request, runtime);
}

model QueryDatasetListRequest {
  workspaceId?: string(name='WorkspaceId'),
  directoryId?: string(name='DirectoryId'),
  withChildren?: boolean(name='WithChildren'),
  keyword?: string(name='Keyword'),
  pageNum?: int32(name='PageNum'),
  pageSize?: int32(name='PageSize'),
}

model QueryDatasetListResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  result?: {
    pageNum?: int32(name='PageNum'),
    data?: [ 
      {
        dataSource?: {
          dsName?: string(name='DsName'),
          dsId?: string(name='DsId'),
          dsType?: string(name='DsType'),
        }(name='DataSource'),
        createTime?: string(name='CreateTime'),
        ownerName?: string(name='OwnerName'),
        workspaceName?: string(name='WorkspaceName'),
        ownerId?: string(name='OwnerId'),
        datasetName?: string(name='DatasetName'),
        rowLevel?: boolean(name='RowLevel'),
        workspaceId?: string(name='WorkspaceId'),
        description?: string(name='Description'),
        directory?: {
          pathName?: string(name='PathName'),
          pathId?: string(name='PathId'),
          name?: string(name='Name'),
          id?: string(name='Id'),
        }(name='Directory'),
        modifyTime?: string(name='ModifyTime'),
        datasetId?: string(name='DatasetId'),
      }
    ](name='Data'),
    totalPages?: int32(name='TotalPages'),
    pageSize?: int32(name='PageSize'),
    totalNum?: int32(name='TotalNum'),
  }(name='Result'),
}

model QueryDatasetListResponse = {
  headers: map[string]string(name='headers'),
  body: QueryDatasetListResponseBody(name='body'),
}

async function queryDatasetListWithOptions(request: QueryDatasetListRequest, runtime: Util.RuntimeOptions): QueryDatasetListResponse {
  Util.validateModel(request);
  var query = {};
  query["WorkspaceId"] = request.workspaceId;
  query["DirectoryId"] = request.directoryId;
  query["WithChildren"] = request.withChildren;
  query["Keyword"] = request.keyword;
  query["PageNum"] = request.pageNum;
  query["PageSize"] = request.pageSize;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'QueryDatasetList',
    version = '2020-08-06',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryDatasetList(request: QueryDatasetListRequest): QueryDatasetListResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryDatasetListWithOptions(request, runtime);
}

